<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
	<title>部门管理</title>
	
	<script>
		$(document).ready(function() {
			//聚焦第一个输入框
			$("#department_deptname").focus();
			//为inputForm注册validate函数
			$("#inputForm").validate();
		});
	</script>
</head>

<body>
<section class="content">
<div class="row">
		<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary">
				<div class="box-header">
					<i class="fa fa-edit"></i>
					<h3 class="box-title">管理部门</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
				<div class="box-body">
	<form id="inputForm" action="${ctx}/department/${action}" method="post" class="form-horizontal">
		<input type="hidden" name="id" value="${department.id}"/>
		<fieldset>
			<div class="form-group">
				<label for="task_title" class="col-sm-3 control-label">部门名:</label>
				<div class="col-sm-6">
					<input type="text" id="department_deptname" name="deptname"  value="${department.deptname}" class="form-control input-large required" minlength="1"/>
				</div>
			</div>	
			<div class="form-group">
				<label for="task_title" class="col-sm-3 control-label">部门介绍:</label>
				<div class="col-sm-6">
					<input type="text" id="department_deptintro" name="deptintro"  value="${department.deptintro}" class="form-control input-large required" minlength="1"/>
				</div>
			</div>	
			<div class="form-group">
				<label for="department_areagroupId" class="col-sm-3 control-label">所属片区:</label>
				<div class="col-sm-6">
					<select id="department_areagroupId" name="areagroupId" class="form-control" >
						<option value="-1"></option>
						<c:forEach items="${areaGroups}" var="areaGroup">
							<option value="${areaGroup.id}" <c:if test="${not empty department.areaGroup and department.areaGroup.id eq areaGroup.id}">selected="selected"</c:if>>${areaGroup.groupName}</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="task_title" class="col-sm-3 control-label">地址:</label>
				<div class="col-sm-6">
					<input type="text" id="department_address" name="address"  value="${department.address}" class="form-control input-large required" minlength="1"/>
				</div>
			</div>
			<div class="form-group">
				<label for="department_parentId" class="col-sm-3 control-label">所属父部门:</label>
				<div class="col-sm-6">
					<select id="department_parentId" name="parentId" class="form-control">
						<option value="-1"></option>
						<c:forEach items="${departments}" var="maps">
							<c:forEach items="${maps}" var="map">
							<option value="${map.key}" <c:if test="${department.department.id eq map.key}">selected="selected"</c:if>>${map.value}</option>
							</c:forEach>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label for="status" class="col-sm-3 control-label">状态:</label>
				<div class="col-sm-6">
					<input type="radio" name="status" value="1" <c:if test="${department.status eq '1' or empty department.status}">checked="checked"</c:if>>有效</input>
					<input type="radio" name="status" value="0" <c:if test="${department.status eq '0'}">checked="checked"</c:if>>无效</input>
				</div>
			</div>
			<div class="modal-footer bg-gray">
				<input id="submit_btn" class="btn btn-primary" type="submit" value="提交"/>&nbsp;	
				<input id="cancel_btn" class="btn" type="button" value="返回" onclick="history.back()"/>
			</div>
		</fieldset>
	</form>
	</div>	
	</div>	
	</div>	
	</div>
	</section>	
</body>
</html>
